package com.teddy.customWidgets;

import org.eclipse.swt.widgets.Tree;

import com.teddy.model.abstracts.SemanticObject;

public class TreeItem extends org.eclipse.swt.widgets.TreeItem {

	private SemanticObject itemObject; 
	public TreeItem(Tree parent, int style, SemanticObject obj ) {
		super( parent, style);
		this.setItemObject(obj);
		this.setText(obj.getName());
	}
	
	public TreeItem(TreeItem parentItem, int style, String URI ){
		super(parentItem, style);
		//this.setURI(URI);
	}
	
	public TreeItem(Tree parent, int style, int index, String URI ) {
		super( parent, style, index );
		//this.setURI(URI);
	}
	
	public TreeItem( TreeItem parentItem, int style, int index, String URI ) {
		super( parentItem, style, index );
		//this.setURI(URI);
	}
	
	protected void checkSubclass() {
		// Disable the check that prevents subclassing of SWT components
	} 
	
	public TreeItem getItem(int index) {
		return (TreeItem)super.getItem(index);
	}
		
	public boolean containsItem( String URI ) {
		int subItemsCount = this.getItemCount();
		for (int i = 0; i < subItemsCount; i++) {
			if( this.getItem( i ).getItemObject().getURI().equals( URI ))
				return true;
		}
		return false;
	}

	public void setItemObject(SemanticObject itemObject) {
		this.itemObject = itemObject;
	}

	public SemanticObject getItemObject() {
		return itemObject;
	}
}
